package customer.zspt.cn.customer.components.chat.ChatOrderContent.OrderElementPg;

import android.content.Context;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;

import customer.zspt.cn.customer.R;
/**
 * Created by Administrator on 2018/8/16 0016.
 */
public class SwitchView extends BaseView {
    private final TextView title;
    private Switch switchView;
    private String result;
    public SwitchView(Context context,String titleVaules,boolean States) {
        super(context,titleVaules);
        View.inflate(context, R.layout.chat_order_content_switch, this);
        switchView = findViewById(R.id.switchView);
        title = (TextView) findViewById(R.id.title);
        title.setText(titleVaules);
        switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                result = isChecked?"是":"否";
            }
        });
    }

    @Override
    public String result() {
        return result;
    }

    private void setCheckState(String state) {
            if(state.equals("是")){
                switchView.setChecked(true);
            }else{
                switchView.setChecked(false);
            }
    }
}
